package com.cweb.admin.model.bbs.bbs_user_to_article.service;

import com.cweb.admin.model.bbs.bbs_user_to_article.entity.BbsUserToArticle;
import com.cweb.admin.model.bbs.bbs_user_to_article.mapper.BbsUserToArticleMapper;
import com.cweb.admin.serivce.authority.UserLoginService;
import com.cweb.framework.base.serivce.BaseMybatisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 论坛-用户收藏文章 服务实现类
 * @since 2020-09-15
 */
@Service
public class BbsUserToArticleService extends BaseMybatisService<BbsUserToArticleMapper, BbsUserToArticle> {
    @Autowired
    private UserLoginService userLoginService;

    /**
     * 追加收藏
     */
    @Transactional
    public Integer add(Long articleId) {
        return this.getBaseMapper().insertLink(userLoginService.getCurLoginUserId(), articleId);
    }
    /**
     * 取消收藏
     */
    @Transactional
    public Object cancel(Long articleId) {
        return this.getBaseMapper().deleteLink(userLoginService.getCurLoginUserId(), articleId);
    }
}
